<?php
namespace app\face\controller;
use think\Controller; 
use think\Db;
use think\Log;
use app\service\wotuService;
class Face extends Controller
{
	public function test()
	{
		$guid="200F006B66304745B7DD6B58756F8671";
		//$image="C:\\phpStudy\\WWW\\zaozao\\public\\uploads\\20191029\\3e8b3664d82ebaf5094440aba047d73a.jpg";
		$image="C:\\phpStudy\\WWW\\zaozao\\public\\uploads\\20191029\\e198914598a60d613092cc75a1dc36da.jpg";
		//$image=(new wotuService())->base64EncodeImage($image);
		$result=(new wotuService())->uploadimg2($image,$guid);
		var_dump($result);die;
        if($result["code"]=="GS_SUS600"){
            $info["photoid"]=$result["data"]["guid"];
            $info["faceurl"]=$result["data"]["faceUrl"];

            return json_encode($info);
        }else{
            echo "<script>alert('图片上传失败，请重新上传');history.go(-1);</script>";
            die;
        }

	}
	//上传图片
	public function uploadimg()
	{
		
		return "OK";
		$info["img_guid"]=$result["data"]["guid"];
        $info["faceurl"]=$result["data"]["faceUrl"];

        return json_encode($info);
		//$user_id=request()->post("user_id");
		$user_id="2088112618452297";
		$userinfo=Db::table("face_user_room")->where("user_id",$user_id)->find();
		$guid=$userinfo["guid"];
		
		$file=request()->file("file");
		Log::write($file,"图片信息");
		return $guid;
		if($file){
		   	$info = $file->move('uploads');
		   
		   	if($info){
		   		$image="C:\\phpStudy\\WWW\\zaozao\\public\\uploads\\".$info->getSaveName();
		   		
				//$image=(new wotuService())->base64EncodeImage($filename);
				$result=(new wotuService())->uploadimg2($image,$guid);
				return json_encode($result);
		        if($result["code"]=="GS_SUS600"){
		            $info["img_guid"]=$result["data"]["guid"];
		            $info["faceurl"]=$result["data"]["faceUrl"];

		            return json_encode($info);
		        }else{
		            echo "<script>alert('图片上传失败，请重新上传');history.go(-1);</script>";
		            die;
		        }
				return $image;
		   }
		}
	}
	//删除图片
	public function delimage(){
        $guid=request()->post("photoid");
        $personGuid=request()->post("personGuid");
        $result=(new wotuService())->delimage($personGuid,$guid);
        //图片删除成功
        if($result["code"]=="GS_SUS601"){
            //$info["photoid"]="0";
            //$info["faceurl"]="0";
            //(new wxService())->wxuserUpdate(session("openid"),$info);
            $arr=array("errcode"=>"0","msg"=>"图片删除成功");
            echo json_encode($arr);
        }else{
            $arr=array("errcode"=>"1","msg"=>"图片删除失败");
            echo json_encode($arr);
        }
    }
	public function useradd($id,$type)
	{
		$userinfo=Db::table("face_user_room")->where("id",$id)->find();
		$type="10";
		$res=(new wotuService())->reg($userinfo["nickname"],$userinfo["phone"],$type,$userinfo["room_address"],"");
		$result=json_decode($res,true);       
        $guid=$result["data"]["guid"];
        Db::table("face_user_room")->where("id",$id)->update(["guid"=>$guid]);
	}
}